/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package datos;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Ing. Monica Merlo, Ing. Agustin  Fernandez
 */
@Entity
@Table(name = "pais")
@NamedQueries({@NamedQuery(name = "Pais.findAll", query = "SELECT p FROM Pais p ORDER BY p.nombre"),
               @NamedQuery(name = "Pais.findById", query = "SELECT p FROM Pais p WHERE p.id = :id"),
               @NamedQuery(name = "Pais.findByIsoNum", query = "SELECT p FROM Pais p WHERE p.isoNum = :isoNum"),
               @NamedQuery(name = "Pais.findByIso2", query = "SELECT p FROM Pais p WHERE p.iso2 = :iso2"),
               @NamedQuery(name = "Pais.findByIso3", query = "SELECT p FROM Pais p WHERE p.iso3 = :iso3"),
               @NamedQuery(name = "Pais.findByNombre", query = "SELECT p FROM Pais p WHERE p.nombre = :nombre"),
               @NamedQuery(name = "Pais.encontrarTodosPaises", query = "SELECT p FROM Pais p ORDER BY p.nombre"),
               @NamedQuery(name = "Pais.encontrarPorNombre", query = "SELECT p FROM Pais p WHERE p.nombre LIKE :nombre ORDER BY p.nombre")
})
public class Pais implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "isoNum")
    private short isoNum;
    @Basic(optional = false)
    @Column(name = "iso2")
    private String iso2;
    @Basic(optional = false)
    @Column(name = "iso3")
    private String iso3;
    @Basic(optional = false)
    @Column(name = "nombre")
    private String nombre;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idPais")
    private Collection<Provincia> provinciaCollection;
    @OneToMany(mappedBy = "idPais")
    private Collection<EmpresaContratista> empresaContratistaCollection;

    public Pais() {
    }

    public Pais(Integer id) {
        this.id = id;
    }

    public Pais(Integer id, short isoNum, String iso2, String iso3, String nombre) {
        this.id = id;
        this.isoNum = isoNum;
        this.iso2 = iso2;
        this.iso3 = iso3;
        this.nombre = nombre;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public short getIsoNum() {
        return isoNum;
    }

    public void setIsoNum(short isoNum) {
        this.isoNum = isoNum;
    }

    public String getIso2() {
        return iso2;
    }

    public void setIso2(String iso2) {
        this.iso2 = iso2;
    }

    public String getIso3() {
        return iso3;
    }

    public void setIso3(String iso3) {
        this.iso3 = iso3;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public Collection<Provincia> getProvinciaCollection() {
        return provinciaCollection;
    }

    public void setProvinciaCollection(Collection<Provincia> provinciaCollection) {
        this.provinciaCollection = provinciaCollection;
    }

    public Collection<EmpresaContratista> getEmpresaContratistaCollection() {
        return empresaContratistaCollection;
    }

    public void setEmpresaContratistaCollection(Collection<EmpresaContratista> empresaContratistaCollection) {
        this.empresaContratistaCollection = empresaContratistaCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Pais)) {
            return false;
        }
        Pais other = (Pais) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "datos.Pais[id=" + id + "]";
    }

}
